import {
    center,
    grid,
    header,
    button,
    search,
} from '@/css/VueCss.module.scss';
export default {
    title: '客户列表',
    order: 1,
    items: [{
        region: 'center',
        class: center,
        layout: 'vertical',
        items: [{
            items: [{
                class: search,
                widget: 'search-datesearch',
                times: [{
                    label: '今日',
                    value: 'today'
                }, {
                    label: '昨日',
                    value: 'yesterday'
                },{
                    label: '近7日',
                    value: 'lately7'
                },{
                    label: '近30日',
                    value: 'lately30'
                }],
                rangeTimes: true,
                selects: [{
                    field: 'industry_uuid',
                    placeholder: '选择所属行业',
                    dictionary: {
                        path: 'common/dictionary/config',
                        params: {
                            name: 'crm_customer_industry',
                        },
                    }
                },{
                    field: 'source_uuid',
                    placeholder: '选择客户来源',
                    dictionary: {
                        path: 'common/dictionary/config',
                        params: {
                            name: 'crm_customer_source',
                        },
                    }
                }],
                text:{
                    field: 'keywords',
                    placeholder: '请输入客户(公司)'
                },
                onSearch: [{
                    action: 'grid-load',
                    target: '$widgets.grid',
                    params: '$params'
                }]
            }, {
                class: header,
                layout: 'horizontal',
                items: [{
                    class: button,
                    widget: 'button',
                    value: '新增',
                    onClick: [{
                        action: 'dialog-show',
                        path: 'Customer/CustomerList/Edit',
                        params: {
                            title:"'新增客户'"
                        },
                        applyActions: [{
                        //     action: 'call',
                        //     target: '$widgets.grid',
                        //     method: 'clearSelection'
                        // }, {
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }],
                        cancelActions: [{
                            action: 'print',
                            description: '取消对话框'
                        }]
                    }]
                }, {
                    class: button,
                    widget: 'button',
                    value: '删除',
                    onClick:[{
                        action:'confirm',
                        title:'删除数据',
                        message:'是否删除勾选数据?',
                        confirm:[{
                            var:'checkedItemIds',
                            action:'array-value',
                            target:'$widgets.grid.checkedItems',
                            key:'id'
                        },{
                            action:'print',
                            description:'列表勾选项',
                            value:'$vars.checkedItemIds'
                        },{
                            action:'service',
                            path:'crm/customer/allremove',
                            params:{
                                id:'$vars.checkedItemIds'
                            }
                        },{
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }]
                    }]
                },{
                    class: button,
                    widget: 'button',
                    value: 'Form',
                    onClick: [{
                        action: 'dialog-show',
                        path: 'Customer/CustomerList/EditForm',
                        params: {
                            title:"'Form分组'"
                        },
                        applyActions: [{
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }],
                        cancelActions: [{
                            action: 'print',
                            description: '取消对话框'
                        }]
                    }]
                }]
            }]
        }, {
            id: 'grid',
            class: grid,
            widget: 'grid',
            service: 'crm/customer/list',
            pageSize: 20,
            columns: [{
                prop: 'name',
                label: '客户名称(公司)',
                minWidth: 220
            }, {
                prop: 'category_uuid',
                label: '客户分类',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_category',
                    },
                },
            }, {
                prop: 'industry_uuid',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_industry',
                    },
                },
                label: '所属行业',
            }, {
                prop: 'source_uuid',
                label: '客户来源',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_source',
                    },
                },
            }, {
                prop: 'status_uuid',
                label: '客户状态',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_status',
                    },
                },
            }, {
                prop: 'level_uuid',
                label: '客户等级',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_level',
                    },
                },
            }, {
                prop: 'stage_uuid',
                label: '当前阶段',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_sale_stage',
                    },
                },
            }, {
                prop: 'label_uuid',
                label: '客户标签',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_label',
                    },
                },
            },{
                prop: 'salesman',
                label: '销售联系人',
                width: 150
            }, {
                prop: 'contact',
                label: '客户联系人',
                width: 150
            }, {
                prop: 'phone',
                label: '手机号码',
                width: 150
            }, {
                prop: 'last_follow_time',
                label: '最近联系',
                width: 180
            }, {
                prop: 'next_plan_time',
                label: '下次跟进',
                width: 180
            }],
            buttons: [{
                value: '编辑',
                onClick: [{
                    action: 'dialog-show',
                    path: 'Customer/CustomerList/Edit',
                    params: {
                        form:'$params',
                        title:"'编辑客户信息'"
                    },
                    applyActions: [{
                        action: 'call',
                        target: '$widgets.grid',
                        method: 'reload'
                    }],
                    cancelActions: [{
                        action: 'print',
                        description: '取消对话框'
                    }]
                }]
            }, {
                value: '详情',
                onClick: [{
                    action: 'dialog-show',
                    path: 'Customer/CustomerList/Details',
                    params: '$params',
                }]
            }, {
                value: '删除',
                type: 'danger',
                onClick: [{
                    action: 'confirm',
                    title: '删除数据',
                    message: '是否删除该条数据?',
                    confirm: [{
                        action: 'service',
                        path: 'crm/customer/remove',
                        params: {
                            id: '$params.id'
                        }
                    }, {
                        action: 'call',
                        target: '$widget',
                        method: 'reload'
                    }]
                }]
            }], 
            flex: true,
            operationWidth:130,
            operationButtonCount:3,
            enableCheckboxColumn: true,
        }]
    }]
};
